Skip to main content

Create a surveillance monitor screen with a raspberry pi

  • Fact : Now that Zabbix is installed, why not have it displayed on a separe screen. I got an old TV so.... let's try.
  • Problem : I don't have a direct ethernet connection.
  • Hypothese : Run the websites needed off a RPi 3+ using a Wifi connection and alternate between them.

Need a good SDcard and Time

  • First problem noted... need a good SDCard. I'm at number 2 already.
  • Also, the 64 bit version of bookworm works but after a few hours, I got the multicolor screen. So down to 32 bit it is.
  • I notice some basic glitches while running htop, not enough memory so I added some extra swap memory :
        sudo dphys-swapfile swapoff
  • Then I edited the configuration (swap) file :
        sudo nano /etc/dphys-swapfile
  • Change this value to something that your SDCard can take and under 2gb if you do not want to mess with other configurations, ex: CONF_SWAPSIZE=2048: swapsize
  • Save and then, reinitialize the swap file :
        sudo dphys-swapfile setup
    sudo dphys-swapfile swapon
  • Reboot to take effect :
        sudo reboot
  • For some reason, the time and date was wrong. I fixed that buy running this :
        sudo timedatectl set-ntp true"
    • To sync with the default ntp server.
        systemctl status systemd-timesyncd
    • To check the status
        sudo systemctl restart systemd-timesyncd
    • To restart it and to check it again
        timedatectl
  • Bingo!

Create a script and install some apps

  • Need to double check what the Pi is currently running for display (Wayland or X11) :

        sudo raspi-config

    raspconfig

  • Then go to 6 Advanced Options - A6 Wayland - W1 X11 openbox window manager with X11 backend (Cause it runs better on a Pi 3+)

  • Reboot!!

  • Next, need to install these's apps :

    • First one is to remove the mouse cursor:
          sudo apt-get install unclutter
    • Second one is to be able to do keyboard functions (like pressing F5 or Ctrl+Tab):
          sudo apt-get install xdotool
  • Time to create the script. In a new file, that I keeped in my user folder :

    • I named it run_fullsize.sh and added this to it :
          export DISPLAY=:0
      sleep 15
      /bin/chromium-browser --kiosk --start-maximized --noerrdialogs --disable-infobars --enable-features=OverlayScrollbar https://time.is/ http://yourZabbixserver &
    • Let's break it down :
      • export DISPLAY=:0 (It's to make sure that the variable $DISPLAY is set to the first and, in my case the, only display)
      • sleep 15 (Since the script will start @BOOT, we want everything to load before it starts... so 15 seconds)
      • /bin/chromium-browser (Starts Chromium with the next parameters) --kiosk (no interaction) --start-maximized (full screen) --noerrdialogs (Don't want to see that ;) --disable-infobars (no tabs above) --enable-features=OverlayScrollbar (no scroll bar) https... (websites wanting to see)
    • Saved it and made it executable : sudo chmod +x run_fullsize.sh
  • Now, before going any further, I ran it to see if it works :

        ./run_fullsize.sh
    • And it works!
    • NOTE : I couldn't find a way to automatically signin in Zabbix so I pluged in a keyboard and mouse, logged in and click the remember me option
  • Then, I killed the process pkill -o chromium (-o is for oldest) and proceed to create 2 more scripts run_keystroke_sim.sh and run_through_tab.sh :

        sleep 35
    while true; do
    sleep 90
    xdotool key F5
    done
    • And :
        export DISPLAY=:0
    while true; do
    sleep 60
    xdotool key ctrl+Tab
    done
  • Break it down :

    • Don't want to refresh right away so (sleep 35)
      • Then refresh every 90 seconds (sleep 90)
    • On the same display and making sure that the variable is the same (export DISPLAY=:0)
      • Then change the web page every minute (sleep 60)

Need to start scripts @ BOOT

  • I changed to autostart file and added and removed some stuff :
        sudo nano /etc/xdg/lxsession/LXDE-pi/autostart
    Autostart
    • Break it down :
      • Not sure what @xset s off @xset -dpms @xset s noblank but we need them
      • To turn off the screen saver # @xscreensaver -no-splash
      • Remove the mouse cursor @unclutter -idle 3 -root
      • Add the 3 scripts :
        • @/home/user/run_fullsize.sh
        • @/home/user/run_through_tab.sh
        • @/home/user/run_keystoke_sim.sh

** Update : After playing with a bit of the features, it seems that we need to copy autostart to the auto login profile :

    mkdir /home/user/.config/lxsession
mkdir /home/user/.config/lxsession/LXDE-pi
cp /etc/xdg/lxsession/LXDE-pi/autostart /home/user/.config/lxsession/LXDE-pi/

While a was using SSH...

  • I kinda notice that the service would lag often and even crash. Did some research and came down with this approach :
    • Need to add IPQoS cs0 cs0 at the end of the /etc/ssh/sshd_config file. I guess it had to do with the Type of service (TOS) setting.